package com.atdel.demo31;


import java.util.Arrays;
import java.util.List;

/**
 * @BelongsProject: java_study
 * @BelongsPackage: com.atdel.demo31
 * @Author: Del
 * @CreateTime: 2025-03-30  16:56
 * @Description: TODO
 * @Version: 1.0
 */
public class MainTest {
    public static void main(String[] args) {
        try {
            // 有效学生
            List<String> hobbies1 = Arrays.asList("篮球", "阅读");
            Student student1 = new Student("张三", "男", hobbies1);
            System.out.println(student1);

            // 无效性别
            try {
                List<String> hobbies2 = Arrays.asList("足球");
                Student student2 = new Student("李四", "女", hobbies2);
                System.out.println(student2);
            } catch (InvalidGenderException e) {
                System.out.println("创建学生失败: " + e.getMessage());
            }

            // 无效爱好
            try {
                List<String> hobbies3 = Arrays.asList("篮球", "足球", "游泳", "游戏");
                Student student3 = new Student("王五", "1", hobbies3);
                System.out.println(student3);
            } catch (InvalidHobbyException e) {
                System.out.println("创建学生失败: " + e.getMessage());
            }

            // 爱好数量超过限制
            try {
                List<String> hobbies4 = Arrays.asList("篮球", "足球", "游泳", "阅读");
                Student student4 = new Student("赵六", "male", hobbies4);
                System.out.println(student4);
            } catch (InvalidHobbyException e) {
                System.out.println("创建学生失败: " + e.getMessage());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
